﻿if exists (select * from sysobjects where id = object_id(N'pBUGLOGUsersAdd') and sysstat & 0xf = 4) drop procedure pBUGLOGUsersAdd 
GO

-- Creates a new record in the [dbo].[Users] table.
CREATE PROCEDURE pBUGLOGUsersAdd
    @p_UserName varchar(25),
    @p_FirstName varchar(25),
    @p_LastName varchar(25),
    @p_Department varchar(50),
    @p_Address varchar(250),
    @p_phoneNumber varchar(50),
    @p_EmailAddress nvarchar(30),
    @p_RegistrationDate smalldatetime,
    @p_RoleID int,
    @p_UserID_out int output
AS
BEGIN
    INSERT
    INTO [dbo].[Users]
        (
            [UserName],
            [FirstName],
            [LastName],
            [Department],
            [Address],
            [phoneNumber],
            [EmailAddress],
            [RegistrationDate],
            [RoleID]
        )
    VALUES
        (
             @p_UserName,
             @p_FirstName,
             @p_LastName,
             @p_Department,
             @p_Address,
             @p_phoneNumber,
             @p_EmailAddress,
             @p_RegistrationDate,
             @p_RoleID
        )

    SET @p_UserID_out = SCOPE_IDENTITY()

END

